﻿@using System.Web.Mvc.Html
@model IQueryable<HomePortal.Models.Post>
@{
    ViewBag.Title = "Все посты";
}
@section featured {
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">
                <h1>@ViewBag.Title.</h1>
                <h2>@ViewBag.Message</h2>
            </hgroup>
        </div>
    </section>
}
<br />
<div class="content">
    @{
        Html.RenderPartial("Search");
    }
</div>
<br/>
<div class="content">
    <nav>
        <ul id="menu" class="leftLinks">
            <li>@Html.ActionLink("Все", "All") </li>
            @{
                Html.RenderAction("ListTags", "Tags");
            }
        </ul>
    </nav>
    <br />
</div>
<br />
@foreach (var item in Model)
{
    <div class="content">
        <h2>
            <a href="/Post/Details/@item.ID">@item.Title</a>
        </h2>
        @{ var rating = 0;
        }

        <h4>@String.Format("{0:g}", item.PublishDate.ToShortDateString()), Автор: @item.Author, 
            Рейтинг: 
            @for (int k = 0; k < @item.Rating; k++)
            {
                rating += k;
                <img class="image_rate" src="~/Content/images/star.png" />
            }
        </h4>
        <div class="photo image_logo" data-title="@item.MiniContent">
            <a href="/Post/Details/@item.ID">
                <img class="image_logo" src="@Url.Content("/Content/images/logos/" + @item.ID + "logo.jpg")" title="@item.MiniContent"/>
            </a>
        </div>
        @*<h5>
            @Html.Raw(@item.MiniContent)
        </h5>*@
               @{
                    if (item.DownloadFileName != null)
                    {
                        <p class="download">@Html.ActionLink("Скачать","Download",new {fileName = item.DownloadFileName},new{@class = "download-file",title= "Скачать торрент файл-"+item.DownloadFileName})</p>     
                    }
                }
        <h5>
            <span>Теги:&nbsp;
                @{
            var i = @item.Tags.Count;
            var j = 1;
                }
                @foreach (var tag in item.Tags)
                {

                    if (i == j)
                    {
                    @Html.RouteLink(tag.Name, new { controller = "Post", action = "Search", id = tag.TagID })
                    <span>.</span>
                    }
                    else
                    {
                    @Html.RouteLink(tag.Name, new { controller = "Post", action = "Search", id = tag.TagID })
                    <span>,</span>
                    }
                    j++;

                }
            </span>
        </h5>
        <p>
            <a href="/Post/Details/@item.ID">Читать далее →</a>
        </p>
    </div>
    <br />
                
}



